﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Example18.aspx.cs" Inherits="Chapter28.Example18" %>

<!DOCTYPE html>

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>代码清单 28-18 使用 insertAdjacentHTML 方法</title>
    <meta name="author" content="Adam Freeman" />
    <meta name="description" content="A simple example" />
    <link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
</head>
<body>
    <p id="textblock">
        There are lots of different kinds of fruit - there are you over 500 varieties 
        of banana alone. By the time we add the countless types of 
        apples, oranges, and other well-known fruit, we are faced with thousands of choices.
    </p>
    <p>
        <button id="insert">Insert Element</button>
    </p>
    <script>
        document.getElementById("insert").onclick = function () {
            var textBlock = document.getElementById("textBlock");
            textblock.firstChild.splitText(19);
            var newText = textblock.childNodes[1].splitText(4).previousSibling;
            textblock.insertBefore(document.createElement("b"), newText).appendChild(newText);
        }
    </script>
</body>
</html>
